//
//  TodoItem.swift
//  Todo-Lists
//
//  Created by stu on 2019/10/8.
//  Copyright © 2019年 stu. All rights reserved.
//

import Foundation

class TodoItem: NSObject,NSCoding {
    func encode(with aCoder: NSCoder) {
        aCoder.encode(text, forKey: "Text")
        aCoder.encode(checked, forKey: "Checked")
        aCoder.encode(dueDate, forKey: "DueDate")
        aCoder.encode(shouldRemind, forKey: "ShouldRemind")
    }
    required init?(coder aDecoder: NSCoder) {
        text = aDecoder.decodeObject(forKey: "Text") as! String
        checked = aDecoder.decodeBool(forKey: "Checked")
        dueDate = aDecoder.decodeObject(forKey: "DueDate") as! Date
        shouldRemind = aDecoder.decodeBool(forKey: "ShouldRemind")
        
        super.init()
    }
    var text = ""
    var checked = false
    var dueDate = Date()
    var shouldRemind = false
    
    override init() {
        super.init()
    }
    
    func scheduleNotification(){
        if shouldRemind && dueDate > Date(){
            
//            let content = UNMutableNotificationContent()
//            
//            content.title = "备忘录:"
//            content.body = text
//            content.sound =
        }
    }
}
